﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Reference.Apps"
    xmlns:common="using:Reference.Apps.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
    x:Name="pageRoot"
    x:Class="Reference.Apps.GroupView"
    mc:Ignorable="d">
    
        <Page.DataContext>
		<Binding Mode="OneWay" Path="Main" Source="{StaticResource VMLocator}"/>
	</Page.DataContext>
	<Page.BottomAppBar>
		<CommandBar RequestedTheme="Light">
			<AppBarButton x:Uid="W8ViewMoreAppBarButton" Icon="Forward" Label="Cargar siguientes">
				<Interactivity:Interaction.Behaviors>
					<Core:EventTriggerBehavior EventName="Click">
						<Core:InvokeCommandAction Command="{Binding GetNextSnippetsCommand, Mode=OneWay}"/>
					</Core:EventTriggerBehavior>
				</Interactivity:Interaction.Behaviors>
			</AppBarButton>
		</CommandBar>
	</Page.BottomAppBar>
    
	<Grid Background="{StaticResource ApplicationPageBackgroundBrush}" DataContext="{Binding Main.SelectedCodeGroup, Source={StaticResource VMLocator}}">
		<Grid.ChildrenTransitions>
			<TransitionCollection>
				<EntranceThemeTransition/>
			</TransitionCollection>
		</Grid.ChildrenTransitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="140"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>

		<!-- Back button and page title -->
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="120"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<Button x:Name="backButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
				Style="{StaticResource MyButtonResource}"
				VerticalAlignment="Top"
				AutomationProperties.Name="Back"
				AutomationProperties.AutomationId="BackButton"
				AutomationProperties.ItemType="Navigation Button" Foreground="{StaticResource ApplicationContrastBackgroundBrush}"/>
			<TextBlock x:Name="pageTitle" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
				IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40" Text="{Binding Name}" Foreground="{StaticResource ApplicationContrastBackgroundBrush}"/>
		</Grid>
        <GridView Grid.Row="1" ItemTemplate="{StaticResource WCodeSnippetTemplate}" ItemsSource="{Binding Snippets}" IsSwipeEnabled="False" SelectionMode="None" Margin="120,0,0,0" IsItemClickEnabled="True" ItemClick="SnippetsListItem_Click"/>
	</Grid>
</Page>
